<template>
    <div>
        <van-nav-bar
          left-text="书吧二维码"
          left-arrow
          @click-left="onClickLeft"
        />
        <div class="main">
            <div class="top">
                <van-button round type="success" size="small" @click="getList">开始盘点</van-button>

                <!-- <van-button round type="success" size="small">继续盘点</van-button>
                <van-button round type="warning" size="small">结束盘点</van-button> -->
            </div>
            <div class="list">
                <h5>已盘书籍列表</h5>
                <van-tabs v-model:active="active" type="line" class="tabs">
                    <van-tab :title="allcount">
                        <van-list
                        :finished="finished"
                        finished-text="没有更多了"
                        :offset="250"
                        >
                        <div class="list-book">
                            <div v-for="item in booksArr" style="display: flex;">
                                <div style="width: 30%;">
                                    <img :src="item.img" alt="">
                                </div>
                                <div style="flex:1;width: 70%;font-size: 14px;">
                                    书名:<span>{{ item.name }}</span>
                                    <div style="display: flex;flex-direction: row;margin-top: 10px;" >
                                        已盘&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        在库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        外借&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        购买
                                    </div>
                                    <div style="margin-top: 10px;">
                                        <span style="margin-right: 40px;">
                                        {{ item.discharged }}
                                    </span>
                                    <span style="margin-right: 40px;">
                                        {{ item.inlibrary }}
                                    </span>
                                    <span style="margin-right: 30px;">
                                        {{ item.lendout }}
                                    </span>
                                    <span>
                                        {{ item.purchase }}
                                    </span>
                                    </div>
                                    

                                </div>
                            </div>
                        </div>
                        </van-list>
                    </van-tab>
                    <van-tab :title="losscount">缺失</van-tab>
                    <van-tab :title="overcount">超出</van-tab>
                </van-tabs>
            </div>

        </div>
       
    </div>
</template>

<script setup lang="ts">
import {ref,reactive} from 'vue'
import { useRouter } from 'vue-router';
import {getstatisticsBook} from '../../../api/goodsApi'

interface IBooks{
    discharged:'',
    id:''
    img:''
    inlibrary:''
    lendout:''
    name:''
    purchase:''
}


let finished = ref<boolean>(false);

let active = ref('0')
let allcount = ref('全部')
let losscount = ref('无')
let overcount = ref('无')

let booksArr:Array<IBooks> = reactive<Array<IBooks>>([])


// 获取盘点列表
const getList = ()=>{
    getstatisticsBook().
    then((res:any)=>{
        console.log(res.data);
        if(res.code == 200){
            finished.value=true;
            booksArr=[res.data]
        }
    })
    // if(res.code == 200){
    //     allcount.value = res.data.allcount
    //     losscount.value = res.data.losscount
    //     overcount.value = res.data.overcount
    // }
}

// 结束盘点


let $router = useRouter()

// 点击返回
function onClickLeft(){
    $router.back()
}
</script>

<style scoped lang="less">
.main{
    width: 100%;
    height: 100%;
}
.top{
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    margin-top: 10px;
}
.list{
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    h5{
        font-size: 14px;
        text-align: center;
        margin-top: 10px;
    }

}
.list-book{
    width: 100%;
    height: 100%;
}
.van-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }


  .van-list__finished-text {
  margin-left: 150px;
}
</style>